package com.wunong.smart.bigdata.flink.job;

import com.wunong.smart.bigdata.flink.function.ExcludeSourceFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author created by zealot.zt
 */
public class StringConnectJob {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment()
                .setParallelism(1);

        // 需要排除的流
        DataStream<String> sourceStream = env.fromElements("DROP", "IGNORE")
                .keyBy(x -> x);

        // 元数据流
        DataStream<String> dataStream = env.fromElements("Apache", "DROP", "Flink", "IGNORE")
                .keyBy(x -> x);

        // connected stream 实现流的关联
        sourceStream.connect(dataStream)
                .flatMap(new ExcludeSourceFunction())
                .print("ConnectResult");

        env.execute(StringConnectJob.class.getName());
    }

}